package com.victualler.business.purchase.controller.impl;

import com.victualler.business.purchase.controller.PrePurchaseOrderController;
import com.victualler.business.purchase.dto.PrePurchaseOrderInfoDto;
import com.victualler.business.purchase.dto.request.PrePurchaseRequestDto;
import com.victualler.business.purchase.entity.PrePurchaseOrderDao;
import com.victualler.business.purchase.repository.PrePurchaseOrderQueryRepository;
import com.victualler.business.purchase.repository.PrePurchaseOrderRepository;
import com.victualler.business.purchase.service.PrePurchaseOrderService;
import com.victualler.core.base.controller.impl.BaseRestControllerImpl;
import com.victualler.core.common.dto.PageDto;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: Guoshichang
 * @discription:    
 */
@RestController
@RequestMapping("/business/purchase/pre")
public class PrePurchaseOrderControllerImpl extends BaseRestControllerImpl<PrePurchaseOrderDao,PrePurchaseOrderRepository,PrePurchaseOrderQueryRepository,PrePurchaseOrderService> implements PrePurchaseOrderController {

    /**
     * @author Guoshichang
     * @since 13:39 on 2018/7/7.
     * @param prePurchaseRequestDto 请求对象
     * @Function  根据条件入参prePurchaseRequestDto动态分页查询权限
     */
    @RequestMapping("/getByRequestDto")
    public PageDto<PrePurchaseOrderDao> getByRequestDto(@RequestBody PrePurchaseRequestDto prePurchaseRequestDto, @RequestParam("pageNo") int pageNo, @RequestParam("limit") int limit) {
        return this.baseService.getByRequestDto(prePurchaseRequestDto,pageNo,limit);
    }

    /**
     * @author Guoshichang
     * @since 13:39 on 2018/7/7.
     * @param id 预订单id
     * @Function  根据条件入参prePurchaseRequestDto动态分页查询权限
     */
    @RequestMapping("/findInfo/{id}")
    public PrePurchaseOrderInfoDto findInfo(@PathVariable("id") Long id) {
        return this.baseService.findInfo(id);
    }

    /**
     * @author Guoshichang
     * @since 13:39 on 2018/7/7.
     * @param prePurchaseOrderInfoDto 预订单实体大对象
     * @Function  保存预订单实体大对象
     */
    @RequestMapping("/saveInfo")
    public void saveInfo(@RequestBody PrePurchaseOrderInfoDto prePurchaseOrderInfoDto) {
        this.baseService.saveInfo(prePurchaseOrderInfoDto);
    }

    /**
     * @author Guoshichang
     * @since 18:01 on 2018/10/9.
     * @param prePurchaseOrderDao 审查大对象
     * @return
     * @Function
     */
    @RequestMapping("/check")
    public void check(@RequestBody PrePurchaseOrderDao prePurchaseOrderDao) {
        this.baseService.check(prePurchaseOrderDao);
    }

    /**
     * @author Guoshichang
     * @since 13:39 on 2018/7/7.
     * @param id 预订单id
     * @Function  根据条件入参prePurchaseRequestDto动态分页查询权限
     */
    @RequestMapping("/deleteInfo/{id}")
    public void deleteInfo(@PathVariable("id") Long id) {
        this.baseService.deleteInfo(id);
    }
}
